package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.JavaBean.Emp;

import java.util.List;

/**
 * @Auther:Liu
 * @Testname:Empmapper
 * @Date:2025/7/31 11:10
 */
@Mapper
public interface Empmapper {
    //    分页查找
    List<Emp> findAll();

    //    查找工作
    @Select("Select distinct job from emp")
    List<String> findAllJob();

    //    查找上司
    @Select("Select empno,ename from emp where state=1")
    List<Emp> findAllMgr();

    //
    @Select("Select count(0) from emp where ename=#{ename}")
    int findEnameCount(String ename);

    //    数据插入
    @Insert("insert into emp values(null,#{ename},#{job},#{mgr},now(),#{sal},#{comm},#{deptno},1) ")
    int save(Emp emp);

    @Delete("update emp set state=0 where empno=#{id} and state=1")
    int removeById(int id);


    int removeByBatch(List<String> ids);

    @Update("update emp set ename=#{ename},job=#{job},mgr=#{mgr},sal=#{sal},comm=#{comm} where empno = #{empno} and state=1")
    int update(Emp emp);

    List<Emp> findCascade(Emp emp);
}
